
/* _____________________________________________________________________________

* 	Paper: Perspective-Taking Through Partisan Eyes
* 	Replication File - Read Me
* 	Date: 2022
* 	Authors: Donald Casler and Dylan Groves, dylanwgroves@gmail.com
________________________________________________________________________________*/


/* Introduction ________________________________________________________________*/

	clear all
	set more off

/* Set Global ___________________________________________________________________*/

	gl stata "X:\Dropbox\Paper - PTinIR\09 Code\07_Replication\"

/* Import Data _________________________________________________________________*/

	use "${stata}\ptinir_data_wave2_raw.dta", clear


/* Clean Data __________________________________________________________________*/


** Overall Treatment Condition
gen treat = .
replace treat = 1 if fl_681_do_fl_686 == "1"
replace treat = 2 if fl_681_do_fl_687 == "1"
replace treat = 3 if fl_681_do_fl_688 == "1"
replace treat = 4 if fl_681_do_fl_689 == "1"
replace treat = 5 if fl_681_do_fl_690 == "1"
replace treat = 6 if fl_681_do_fl_691 == "1"


# d;
lab def treat
	1 "India Climate"
	2 "India Nukes"
	3 "China Climate"
	4 "China Nukes"
	5 "Control Climate"
	6 "Control Nukes" ;
#d cr 

lab val treat treat
lab var treat "Treatment Condition"


** Treatment Country
gen treat_c = .
replace treat_c = 0 if treat == 5 | treat == 6
replace treat_c = 1 if treat == 1 | treat == 2
replace treat_c = 2 if treat == 3 | treat == 4
 
lab def treat_c 0 "Control" 1 "India" 2 "China"
lab val treat_c treat_c

** Treatment Topic
gen treat_t = .
replace treat_t = 0 if treat == 1 | treat == 3 | treat == 5
replace treat_t = 1 if treat == 2 | treat == 4 | treat == 6

lab def treat_t 0 "Climate" 1 "Nukes"
lab val treat_t treat_t

** Treatment
gen treat_pt = .
replace treat_pt = 0 if treat == 5 | treat == 6
replace treat_pt = 1 if treat == 1 | treat == 2 | treat == 3 | treat == 4 

lab def treat_pt 1 "PT Treat" 0 "Control"


*-------------------------------------------------------------------------------
* Covariates
*-------------------------------------------------------------------------------

** Political Covarations
gen c_pid = .
replace c_pid = 3 if pid_3 == "Democrat"
replace c_pid = 2 if pid_3 == "Independent"
replace c_pid = 1 if pid_3 == "Republican"
replace c_pid = .o if pid_3 == "Other"

lab def c_pid 3 "Democrat" 2 "Independent" 1 "Republican" .o "Other"
lab val c_pid c_pid
lab var c_pid "Party ID"

gen c_pid_long = .
replace c_pid_long = 1 if pid_rep == "Strong"
replace c_pid_long = 2 if pid_rep == "Not very strong"
replace c_pid_long = 3 if c_pid == 2
replace c_pid_long = 4 if pid_dem == "Not very strong"
replace c_pid_long = 5 if pid_dem == "Strong"

lab def c_pid_long 1 "Strong Rep" 2 "Rep" 3 "Independent" 4 "Dem" 5 "Strong Dem"
lab val c_pid_long c_pid_long
lab var c_pid_long "Strength of Party ID"

gen c_dem = .
replace c_dem = 1 if pid_3 == "Democrat"
replace c_dem = 0 if pid_3 != "Democrat"

lab def c_dem 0 "Not Dem" 1 "Dem"
lab val c_dem c_dem
lab var c_dem "Democrat Dummy"

gen c_attention = .
replace c_attention = 0 if pol_attent == "Never"
replace c_attention = 1 if pol_attent == "Some of the time"
replace c_attention = 2 if pol_attent == "About half the time"
replace c_attention = 3 if pol_attent == "Most of the time"
replace c_attention = 4 if pol_attent == "Always"

lab def c_attention 0 "Never" 1 "Sometimes" 2 "Half" 3 "Most" 4 "Always"
lab val c_attention c_attention
lab var c_attention "How often do you pay attention to what's going on in government and politics?"

** Democraphic Covariates
gen c_age = .
replace c_age = 18 if age_demos == "18 - 24"
replace c_age = 25 if age_demos == "25 - 34"
replace c_age = 35 if age_demos == "35 - 44"
replace c_age = 45 if age_demos == "45 - 54"
replace c_age = 55 if age_demos == "55 - 64"
replace c_age = 65 if age_demos == "65 - 74"
replace c_age = 75 if age_demos == "75 - 84"
replace c_age = 85 if age_demos == "85 or older"

gen c_state = state_demos

gen c_male = .
replace c_male = 1 if gender_demos == "Male"
replace c_male = 0 if gender_demos == "Female"
replace c_male = 0 if gender_demos == "Other / Prefer not to say"

gen c_edu = .
replace c_edu = 1 if educ_7_demos == "Less than high school"
replace c_edu = 2 if educ_7_demos == "High school graduate"
replace c_edu = 3 if educ_7_demos == "Some college"
replace c_edu = 4 if educ_7_demos == "2 year degree"
replace c_edu = 4 if educ_7_demos == "4 year degree"
replace c_edu = 5 if educ_7_demos == "Professional degree"
replace c_edu = 6 if educ_7_demos == "Doctorate"

lab def c_edu 1 "No High School" 2 "High School" 3 "Some college" 4 "College Degree" 5 "Professional degree" 6 "Doctorate"
lab val c_edu c_edu
lab var c_edu "Level of education"

gen c_race = race_demos

gen c_white = .
replace c_white = 1 if race_demos == "White"
replace c_white = 0 if race_demos != "White"
replace c_white = 0 if ethnicity_demos == "Yes"

gen c_black = .
replace c_black = 1 if race_demos == "Black or African American"
replace c_black = 0 if race_demos != "Black or African American"

gen c_latino = .
replace c_latino = 1 if ethnicity_demos == "Yes"
replace c_latino = 0 if ethnicity_demos != "Yes"

rename ideo_7_1 c_ideology
destring c_ideology, gen(sb_ideology)
drop c_ideology

	recode sb_ideology 	(1 = 7 "Very conservative") ///
						(2 = 6 "Moderately conservative") ///
						(3 = 5 "Somewhat conservative") ///
						(4 = 4 "Neither liberal nor conservative") ///
						(5 = 3 "Somewhat liberal") ///
						(6 = 2 "Moderately liberal") ///
						(7 = 1 "Very liberal"), ///
						gen(c_ideology)


*-------------------------------------------------------------------------------
* Manipulation Check
*-------------------------------------------------------------------------------

gen manip_check = .
replace manip_check = 1 if q591 == "Climate change" & treat_t == 0
replace manip_check = 1 if q591 == "Nuclear weapons" & treat_t == 1
replace manip_check = 0 if q591 == "I don't recall"
replace manip_check = 0 if q591 == "Climate change" & treat_t == 1
replace manip_check = 0 if q591 == "Nuclear weapons" & treat_t == 0


*-------------------------------------------------------------------------------
* Outcome Variables
*-------------------------------------------------------------------------------

* Main Outcome
gen dv_coop = .
replace dv_coop = 1 if q587 == "Strongly oppose" | q597 == "Strongly oppose"
replace dv_coop = 2 if q587 == "Somewhat oppose" | q597 == "Somewhat oppose"
replace dv_coop = 3 if q587 == "Neither support nor oppose" | q597 == "Neither support nor oppose"
replace dv_coop = 4 if q587 == "Somewhat support" | q597 == "Somewhat support"
replace dv_coop = 5 if q587 == "Strongly support" | q597 == "Strongly support"

# d;
lab def dv_coop
	1 "Strongly Oppose"
	2 "Somewhat Oppose"
	3 "Neither"
	4 "Somewhat support"
	5 "Strongly support" ;
#d cr 

lab val dv_coop dv_coop

* Dummy Outcome
gen dv_coop_dum = .
replace dv_coop_dum = 1 if dv_coop == 4 | dv_coop == 5
replace dv_coop_dum = 0 if dv_coop == 1 | dv_coop == 2 | dv_coop == 3

lab def dv_coop_dum 0 "Dont support" 1 "Support"
lab val dv_coop_dum dv_coop_dum

* End of Survey Outcome
gen dv_end = .
replace dv_end = 1 if q621 == "Strongly disagree"
replace dv_end = 2 if q621 == "Somewhat disagree"
replace dv_end = 3 if q621 == "Neither agree nor disagree"
replace dv_end = 4 if q621 == "Somewhat agree"
replace dv_end = 5 if q621 == "Strongly agree"

lab def dv_end 1 "Strong disagree" 2 "Disagree" 3 "Neither" 4 "Agree" 5 "Strong agree"
lab val dv_end dv_end
lab var dv_end "It is essential for the United States to cooperate with other nations to address problems such as climate change and the development of new nuclear weapons."

gen dv_end_dum = .	
replace dv_end_dum = 1 if dv_end == 4 | dv_end == 5
replace dv_end_dum = 0 if dv_end == 1 | dv_end == 2 | dv_end == 3

lab def dv_end_dum 1 "Agree" 0 "Disagree"
lab val dv_end_dum dv_end_dum
lab var dv_end_dum "It is essential for the United States to cooperate with other nations to address problems such as climate change and the development of new nuclear weapons."

gen dv_qual = q589


*-------------------------------------------------------------------------------
* Inverse Probability Weighting
*-------------------------------------------------------------------------------

* IPW
gen ipw = .
replace ipw = 1/(2/3) if treat_pt == 1 & wave == 3
replace ipw = 1/(1/3) if treat_pt == 0 & wave == 3

replace wave = 2 // Originally considered mturk two separate waves, but in final paper consider all mturk to be wave 1, so lucid is wave 2

*-------------------------------------------------------------------------------
* Mechanism
*-------------------------------------------------------------------------------

gen mech_coop = .
replace mech_coop = 1 if q585 == "Accept climate treaty requirements (reduce carbon emissions by taxing energy)"
replace mech_coop = 0 if q585 == "Reject climate treaty requirements (do not reduce carbon emission by taxing energy)"
replace mech_coop = 1 if q595 == "Accept nuclear treaty requirements (stop development and production of tactical nuclear weapons)"
replace mech_coop = 0 if q595 == "Reject nuclear treaty requirements (continue development and production of tactical nuclear weapons)"
replace mech_coop = 1 if q605 == "Accept nuclear treaty requirements (stop development and production of tactical nuclear weapons)"
replace mech_coop = 0 if q605 == "Reject nuclear treaty requirements (continue development and production of tactical nuclear weapons)"
replace mech_coop = 1 if q601 == "Accept climate treaty requirements (reduce carbon emissions by taxing energy)"
replace mech_coop = 0 if q601 == "Reject climate treaty requirements (do not reduce carbon emission by taxing energy)"


*-------------------------------------------------------------------------------
* Save
*-------------------------------------------------------------------------------

keep treat_pt treat_t treat_c dv_coop dv_coop_dum c_age c_dem c_edu c_male c_pid c_pid_long c_white c_black c_latino mech_coop manip_check wave dv_qual c_attention c_ideology u_id ipw svy_duration dv_qual_omit
save "${stata}\ptinir_data_wave2_clean.dta", replace

